package com.bawei.base.utils.ApiService

import com.bawei.base.utils.Conetant
import com.bawei.base.utils.bean.AddCarEntity
import com.bawei.base.utils.bean.AddressEntity
import com.bawei.base.utils.bean.AddresslisetEntity
import com.bawei.base.utils.bean.CarEntity
import com.bawei.base.utils.bean.CategoryEntity
import com.bawei.base.utils.bean.CodeEntity
import com.bawei.base.utils.bean.CouponsEntity
import com.bawei.base.utils.bean.GoodEnttiy
import com.bawei.base.utils.bean.IndexEntity
import com.bawei.base.utils.bean.LoginEntity
import com.bawei.base.utils.bean.LqCouponsEntity
import com.bawei.base.utils.bean.OrderEntity
import com.bawei.base.utils.bean.Res
import com.bawei.base.utils.bean.UserEntity
import com.bawei.base.utils.bean.XqEntity
import com.bawei.base.utils.param.Paddress
import com.bawei.base.utils.param.Poeder
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {

    //挂起函数登录,需要被协成调用
    @POST(Conetant.LOGINUSER)
    suspend fun login(@Body body: RequestBody) : Res<LoginEntity>

    //获取验证码
    @POST("/api/front/sendCode")
    suspend fun getCode(@Query("phone")phone:String) : Res<CodeEntity>

    //验证码登录
    @POST("/api/front/login/mobile")
    suspend fun codeLogin(@Body body: RequestBody) : Res<LoginEntity>

    //获取个人用户信息
    @GET("/api/front/user")
    suspend fun userIfo() : Res<UserEntity>

    //修改密码
    @POST("/api/front/register/reset")
    suspend fun xiugai(@Body body: RequestBody) : Res<Boolean>

    //获取首页
    @GET("/api/front/index")
    suspend fun index() : Res<IndexEntity>

    //首页商品
    @GET("/api/front/index/product/{type}")
    suspend fun indexGoods(@Path("type")type:Int,@Query("limit")limit:Int,@Query("page")page:Int) : Res<GoodEnttiy>

    //获取优惠卷
    @GET("/api/front/coupons")
    suspend fun getcoupons(@Query("limit")limit:Int,@Query("page")page:Int,@Query("type")type:Int) : Res<CouponsEntity>

    //领取优惠卷
    @POST("/api/front/coupon/receive")
    suspend fun receive(@Body body: RequestBody) : Res<String>

    //查看优惠卷
    @GET("/api/front/coupon/list")
    suspend fun viewcoupons(@Query("limit")limit:String,@Query("page")page:String,@Query("type")type:String) : Res<LqCouponsEntity>

    //搜索商品
    @GET("/api/front/products")
    suspend fun searchGoods(@Query("cid")cid:Int,
                            @Query("keyword")keyword:String,
                            @Query("limit")limit:Int,
                            @Query("news")news:Boolean,
                            @Query("page")page:Int,
                            @Query("priceOrder")priceOrder:String,
                            @Query("salesOrder")salesOrder:String) : Res<GoodEnttiy>

    //商品详情页
    @GET("/api/front/product/detail/{id}")
    suspend fun goodsxq(@Path("id")id:Int,@Query("type")type:String) : Res<XqEntity>

    //优品推荐
    @GET("/api/front/product/good")
    suspend fun goodsYp() : Res<GoodEnttiy>

    //收藏
    @POST("/api/front/collect/add")
    suspend fun share(@Body body: RequestBody) : Res<String>

    //取消收藏
    @POST("/api/front/collect/cancel/{proId}")
    suspend fun noshare(@Path("proId")proId:Int) : Res<String>

    //添加购物车
    @POST("/api/front/cart/save")
    suspend fun addcar(@Body body: RequestBody) : Res<AddCarEntity>

    //获取购物车
    @GET("/api/front/cart/list")
    suspend fun getCat(@Query("isValid")isValid:String,@Query("limit")limit:Int,@Query("page")page:Int) : Res<CarEntity>

    //更新购物车数据
    @POST("/api/front/cart/num")
    suspend fun updateCar(@Query("id")id:Int,@Query("number")number:Int) : Res<String?>

    //删除购物车
    @POST("/api/front/cart/delete")
    suspend fun delcar(@Query("ids")ids: Array<Int>) : Res<String?>

    //获取地址列表
    @POST("/api/front/address/edit")
    suspend fun address(@Body paddress: Paddress) : Res<AddressEntity>

    //获取地址所有列表
    @GET("/api/front/address/list")
    suspend fun addresslist(@Query("limit")limit:Int,@Query("page")page:Int) : Res<AddresslisetEntity>

    //设为默认地址
    @POST("/api/front/address/default/set")
    suspend fun moren(@Body body: RequestBody) : Res<String?>

    //删除地址
    @POST("/api/front/address/del")
    suspend fun deladdress(@Body body: RequestBody) : Res<String?>

    //商品分类
    @GET("/api/front/category")
    suspend fun category() : Res<CategoryEntity>

    //预下单
    @POST("/api/front/order/pre/order")
    suspend fun order(@Body poeder: Poeder) : Res<OrderEntity>

    //加载预下单


}